package freespiritsocial.io.user.viewmodel.delegates

import freespiritsocial.io.user.data.model.bean.UserInfo
import freespiritsocial.io.user.network.apiService
import freespiritsocial.io.user.util.CacheUtil
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request

open class UserInfoViewModel: BaseViewModel() {
    private val mineInfo by lazy(LazyThreadSafetyMode.NONE) {
        CacheUtil.getUser()
    }

    fun getUserInfo(id: String?,action: (UserInfo) -> Unit) {
        if (mineInfo?.userId == id) return
        request({
            apiService.getUserInfo(id)
        },{
            action(it)
        },isShowDialog = true)
    }
}